;*******************************************************************************
; Title:	TestACS
; Author:	Fred Graute
; Copyright:	(C) Fred Graute 2006
; Version:	1.06, Sunday the 7th of May, 2006
;
; Changes:	Converted to ObjAsm source code by Philip Ludlam
;		Updated for the A9home by Fred Graute
;
;*******************************************************************************
; This program is free software; you can redistribute it and/or modify it
; under the terms of the GNU General Public License as published by the Free
; Software Foundation; either version 2 of the License, or (at your option)
; any later version.
;
; This program is distributed in the hope that it will be useful, but WITHOUT
; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
; FITNESS FOR APARTICULAR PURPOSE. See the GNU General Public License for more
; details.
;
; You should have received a copy of the GNU General Public License along with
; this program; if not, write to the Free Software Foundation, Inc., 59 Temple
; Place - Suite 330, Boston, MA 02111-1307, USA
;
;*******************************************************************************

		TTL	> TestACS

		GET	OSLib:oslib.hdr.types
		GET	OSLib:oslib.hdr.OS
		GET	OSLib:oslib.hdr.OSByte
		GET	AsmLib2:hdr.RegsBoth

		AREA	|main|, CODE, READONLY

		ENTRY

;-------------------------------------------------------------------------------
Start		B	Entry			; Entry instruction
		DCD	&79766748		; Magic value 1
		DCD	&216C6776		; Magic value 2
		DCD	End-Start		; Read only size
		DCD	0			; Read/write size
		DCD	32			; 26 or 32 bit build

Entry		MOV	r9, #2			;
		ADR	r8, VarNames		; -> list of variable names

Loop		MOV	r7, #0			; 0,1,2,3 = none,left,right,both
		MOV	r0, #&79		; reason = &79 => scan keyboard

		ADD	r1, r9, #&83		; test left modifier key
		SWI	XOS_Byte		; returns &FF if pressed, else 0
		MOVVS	r1, #0			; if error then not pressed
		CMP	r1, #&FF		; return EQ if pressed, else NE
		ORREQ	r7, r7, #1		; if left key pressed set bit 0

		ADD	r1, r9, #&86		; test right modifier key
		SWI	XOS_Byte		; returns &FF if pressed, else 0
		MOVVS	r1, #0			; if error then not pressed
		CMP	r1, #&FF		; return EQ if pressed, else NE
		ORREQ	r7, r7, #2		; if right key pressed set bit 1

		STR	r7, [r12, #0]		; store value to set variable to

		ADD	r0, r8, r9, LSL #4	; -> variable name
		ADD	r1, r12, #0		; -> value to set variable to
		MOV	r2, #4			; size of value, 4 since integer
		MOV	r3, #0			; 0 => no name pointer
		MOV	r4, #1			; 1 => variable is an integer
		SWI	XOS_SetVarVal		; assign value to variable

		SUBS	r9, r9, #1		;
		BPL	Loop			;

		MOV	pc, lr			; say bye bye

VarNames
VarShift	DCB	"Shift$Pressed"
		DCB	0			; variables must be 16 bytes
		ALIGN				; apart

VarCtrl		DCB	"Ctrl$Pressed"
		DCB	0
		ALIGN

VarAlt		DCB	"Alt$Pressed"
		DCB	0

Licence		DCB	" FJG, 2006. Licence: GPL."
		ALIGN

End
		END
